package cn.com.ldns.opentetris.shape;

import javax.microedition.khronos.opengles.GL10;

public class Square extends BaseShape {
	private static float vertices[] = {
			-1.0f,-1.0f,0.0f,
			 1.0f,-1.0f,0.0f,
			 1.0f, 1.0f,0.0f,
			-1.0f, 1.0f,0.0f,
	};

	private static short indices[] = {0,1,2,0,2,3};
	
	public Square() {
		super(vertices, indices);
	}
	
	public Square(float[] vertex) {
		super(vertex, null, null);
	}
	
	public Square(float[] vertex, short[] index) {
		super(vertex, index, null);
	}
	
	public Square(float[] vertex, float[] color) {
		super(vertex, null, color);
	}
	
	public Square(float[] vertex, float[] color,float[] texture) {
		super(vertex, null, color);
	}
	
	@Override
	public void draw(GL10 gl) {
		super.draw(gl);
		gl.glDrawArrays(GL10.GL_TRIANGLE_FAN, 0, vertex.length / 3);
		gl.glDisableClientState(GL10.GL_VERTEX_ARRAY);
		if(textureID != -1 || textureBuff != null)
		{
			gl.glDisable(GL10.GL_TEXTURE_2D);
			gl.glDisableClientState(GL10.GL_TEXTURE_COORD_ARRAY);
		}
	}
}
